
#ifndef __H_SYMPHONY_EXIT
#define __H_SYMPHONY_EXIT

#include "mysql.h"
#include "symphony.h"

// Directions...
#define UNDEFINED -1
#define NORTH     0
#define EAST      1
#define SOUTH     2
#define WEST      3
#define UP        4
#define DOWN      5

// Flags...
#define EFLAG_UNDEFINED   0
#define EFLAG_CLOSEABLE   A
#define EFLAG_CLOSED      B
#define EFLAG_LOCKABLE    C
#define EFLAG_LOCKED      D
#define EFLAG_HIDDEN      E

class Room;



class Exit {
  private:
    unsigned long         _ID;
    Room*                 _target;
    unsigned short        _direction;
    unsigned long         _flags;
    unsigned long         _key;

  public:
    Exit( Room* target, ROW& row );
    Exit( Room* room, Room* target, const unsigned short& direction );
    ~Exit( void );

    // Public accessor methods...
    void                  ID( const unsigned long& ID )                                             { _ID = ID; }
    unsigned long         ID( void ) const                                                          { return _ID; }
    void                  target( Room* target )                                                    { _target = target; }
    Room*                 target( void )                                                            { return _target; }
    void                  direction( const unsigned short& direction )                              { _direction = direction; }
    unsigned short        direction( void ) const                                                   { return _direction; }
    void                  flags( const unsigned long& flags )                                       { _flags = flags; }
    unsigned long         flags( void ) const                                                       { return _flags; }
    void                  flag( const unsigned long& flag, const bool& value, bool stop = false );
    bool                  flag( const unsigned long& flag )                                         { return ( (flags()&flag) == flag ); }
    void                  key( const unsigned long& key )                                           { _key = key; }
    unsigned long         key( void ) const                                                         { return _key; }

    // General methods...
    void                  save( void );
    void                  destroy( void );
    std::string           listFlags( void );

    // Statics...
    static unsigned short inverse( const unsigned short& direction );
    static const char*    name( const unsigned short& direction );
    static const char*    inverseName( const unsigned short& direction );
    static unsigned short string2dir( const std::string& str );
    static unsigned short string2inverse( const std::string& str );
    static const char*    getFlagName( const unsigned long& flag );
    static unsigned long  getFlagType( const std::string& flag );
};



#endif // #ifndef __H_SYMPHONY_EXIT

